# -*- coding: utf-8 -*-

# -------------------------------
# Author    : linlingwei
# Email     : 951035650@qq.com
# File Name : setup.py
# Date      : 2019/7/24 
# IDE       : PyCharm
# Version   : 1.0.1
# -------------------------------

import os
import getpass


def makeBat(batPath,batData):
    versions = [2017, 2018]
    for ver in versions:
        with open(os.path.join(batPath, "maya_default_{}.bat".format(ver)), "w") as bf:
            bf.write(batData.format(version=ver, scriptPath=os.path.split(__file__)[0]))
    return


batData = r"""

@ECHO ON
SET APP_ROOT_DIR=C:\Program Files
SET MAYA_VERSION={version}
SET MAYA_APP_ROOT_DIR=%APP_ROOT_DIR%\Autodesk

SET DEV_SCRIPT_DIR={scriptPath}

SET MAYA_SCRIPT_PATH=%MAYA_SCRIPT_PATH%;%DEV_SCRIPT_DIR%\scripts
SET MAYA_PLUG_IN_PATH=%MAYA_PLUG_IN_PATH%;%DEV_SCRIPT_DIR%\plug-ins

SET PATH=%PATH%;%MAYA_APP_ROOT_DIR%\Maya%MAYA_VERSION%\bin

SET PYTHONPATH=%PYTHONPATH%;%DEV_SCRIPT_DIR%

python %DEV_SCRIPT_DIR%\scripts\launchSetup.py maya {version}

"""

user = getpass.getuser()
outputPath = r"C:\Users\{}\Desktop".format(user)
batPath = os.path.join(outputPath,"mayaLaunch")
if os.path.exists(batPath):
    makeBat(batPath,batData)
else:
    os.makedirs(batPath)
    makeBat(batPath,batData)


if __name__ == '__main__':
    pass